package com.rimi.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @Author luc
 * @Date 2021/7/1
 */
public class PwdUtil {

    private static String algorithmName = "md5";

    private static Integer hashIterations = 10;

    private static Object salt = "j2101";

    public static ByteSource salt() {
        return ByteSource.Util.bytes(salt);
    }

    /**
     *  加密
     * @param password
     * @return
     */
    public static String encode(String password) {
        SimpleHash simpleHash = new SimpleHash(algorithmName,password,salt,hashIterations);
        return simpleHash.toHex();
    }

    public static void main(String[] args) {

        String encode = PwdUtil.encode("123");
        System.out.println(encode);
    }

}
